package com.ycg.vue.modules.user.mapper;

import com.ycg.vue.Annotation.AutoInsert;
import com.ycg.vue.Entity.UserEntity;
import com.ycg.vue.Enum.AutoInsertType;
import com.ycg.vue.result.Result;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

/**
 * @Description
 * @Author jink
 * @Date 2024/1/5
 */
@Mapper
public interface UserMapper {

    UserEntity login(@Param("userName") String userName, @Param("password") String password);

    @AutoInsert(value = AutoInsertType.REGISTER)
    void register(@Param("user") UserEntity user);

    @Select(value = "SELECT COUNT(*) FROM user WHERE username=#{username} OR email=#{username}")
    Integer selectByUserName(@Param("username") String username);

    @Select(value = "SELECT COUNT(*) FROM user WHERE username=#{username} AND password=#{password}")
    Integer selectByPassword(@Param("username") String username, @Param("password") String password);

    UserEntity selectByGroupId(@Param("id") String id);

    @Update("UPDATE user SET head_image = #{headImage} WHERE id = #{id}")
    void updateHeadImage(@Param("headImage") String headImage,@Param("id") String id);

    @Select("SELECT * FROM user WHERE id = #{id}")
     UserEntity selectByUserId(@Param("id") String id);

    @Update("UPDATE user SET password = #{password} WHERE id = #{id}")
    void updatePassword(@Param("password") String password,@Param("id") String id);
}
